<%
'--------------------------------------------------------------------------
'	ADO CONSTANTS USED:
'--------------------------------------------------------------------------
'******	Const adExecuteNoRecords = 
Public Const adCmdText = 1 
Public Const adUseClient = 3
Public Const adLockBatchOptimistic = 4  
Public Const adOpenStatic = 3 
Class DALayer
	'--------------------------------------------------------------------------
	'	This Script Provides A Set Of Common Functions Used
	'	With ADO to Access Data And Execute Queries.
	'	Methods:
	'		RetrieveRS [Returns a Disconnected ADO Recordset]
	'			Inputs:
	'				sSQL-String-Statement to be Executed
	'		ExecuteQuery [Executes a SQL Query]
	'			Inputs:
	'				sSQL-String-Statement to be Executed
	'		SaveRS [Batch Updates a Record Set]
	'			Inputs:
	'				objRS-RecordSet used to update database
	'--------------------------------------------------------------------------
	
	'--------------------------------------------------------------------------
	'Connection String Property
	'--------------------------------------------------------------------------
	Public sConn
	
	Public Property Let ConnectionString(strData)
		sConn = strData	
	End Property
	
	Public Property Get ConnectionString()
		ConnectionString = sConn
	End Property
	
	'--------------------------------------------------------------------------
	'	ExecuteQuery() Executes a Query Returning No Records
	'--------------------------------------------------------------------------
	Public Sub ExecuteQuery(sSQL)
		Dim objConn 
		Set objConn = Server.CreateObject("ADODB.CONNECTION")
		objConn.ConnectionString = sConn
		objConn.Open
		objConn.Execute sSQL, , adCmdText
		Set objConn = Nothing
	End Sub
	
	'--------------------------------------------------------------------------
	'	RetrieveRS() Executes a Query & Retrieves a Disconnected Recordset
	'--------------------------------------------------------------------------
	Public Function RetrieveRS(sSQL)
		Dim objConn, objRS
		Set objConn = Server.CreateObject("ADODB.CONNECTION")
		Set objRS = Server.CreateObject("ADODB.RecordSet")
		objConn.ConnectionString = sConn
		objConn.Open
	  	objRS.CursorLocation = adUseClient
		objRS.CursorType = adOpenStatic	
		objRS.LockType = adLockBatchOptimistic
		objRS.Open sSQL, objConn, , , adCmdText
	 	Set objRS.ActiveConnection = Nothing
		Set RetrieveRS = objRS
		Set objRS = Nothing
		Set objConn = Nothing
	End Function
	
	'--------------------------------------------------------------------------
	'	SaveRS() Updates DataSource Using a Disconnected Recordset
	'--------------------------------------------------------------------------
	Public Sub SaveRS(objRS)
		Dim objConn
		Set objConn = Server.CreateObject("ADODB.CONNECTION")
		objConn.ConnectionString = sConn
		objConn.Open
		Set objRS.ActiveConnection = objConn
		objRS.UpdateBatch
		Set objRS = Nothing
		Set objConn = Nothing
	End Sub
End Class
%>